using Dou;
using Dou.ScreenController;
using Dou.Timer;

public class ScreenControllerMain : AbstractGameMain
{
    protected override void Awake()
    {
        base.Awake();
    }
    
#if UNITY_EDITOR
    
    protected override void OnEditorInit()
    {
        base.OnEditorInit();
    }
    
#endif

    protected override void OnInit()
    {
        // 对于已经放在场景中的GO，需要等待一帧再初始化屏幕管理器，否则屏幕管理器执行的屏幕适配无效
        TimerManager.CallLater((object[] args) =>
        {
            ScreenManager.instance.Init();
            ScreenManager.instance.onScreenIsLandscapeChanged += isLandscape =>
            {
                ScreenUIAdapterMgr.instance.uiScreenMode = isLandscape ? UIScreenMode.Landscape : UIScreenMode.Portrait;
            };
            ScreenUIAdapterMgr.instance.Init(1920, 1080, 0);
            
#if UNITY_EDITOR
            // 编辑器下自动识别下横竖屏
            ScreenManager.instance.mode = ScreenManager.instance.isLandscape ? ScreenMode.Landscape : ScreenMode.Portrait;
#else
            // 运行时按照玩家设置确定横竖屏模式
            ScreenManager.instance.mode = ScreenMode.Landscape;
#endif

        });
    }

    protected override void Start()
    {
        base.Start();
    }

    protected override void FixedUpdate()
    {
        base.FixedUpdate();
    }

    protected override void Update()
    {
        base.Update();
    }

    protected override void LateUpdate()
    {
        base.LateUpdate();
    }

    protected override void OnApplicationPause(bool pause)
    {
        base.OnApplicationPause(pause);
    }

    protected override void OnApplicationFocus(bool focus)
    {
        base.OnApplicationFocus(focus);
    }

    protected override void OnApplicationQuit()
    {
        base.OnApplicationQuit();
    }
}
